#include "gtest/gtest.h"

/*
#include <helper/Result.h>

using namespace helper;
//Restart; 
//create Table
//Drop Table
//Get Table
//Count Table
//Scan Tables
//Compact->CheckPoint

class Version {
public:
};
class VersionSet {
public:
	void append(Version * base){
	}
};

class MetaDB {
public:
	// assert -> dir is not exist
	static std::pair<bool, MetaDB*> Open(const std::string & dir){
		auto * ret = new Meta(dir);
		return ret.open().isOK() 
			? std::make_pair(true, ret) 
			: std::make_pair(false, nullptr);
	}

	// new VersionSet in mm
	// new Version.base in mm
	MetaDB(const std::string & dir)
	:_dir(dir)
	{
	}
	~MetaDB(){
	}

	
	//versionset
	Result<> open(){
		Version * base = new Version(); // ref = 1
		Result<> ret = exist(_dir) ?
				recover(dir, *base) : 
				createEmptyDB(dir, *base);

		_vs.append(base); //ref++ ?
		_current = base;
		delete base; //decrease the scope new 
		return ret;
	}
	Result<> close() {
		//TODO: 
		return Result<>::OK();
	}
private:
	bool exist(const std::string & dir) {
		return false;
	}
	Result<> recover(const std::string & dir, Version & base){
		//read manifest
		//rebase the manifest file 
		//set CURRENT file
		return Result<>::OK();
	}

	Result<> createEmptyDB(const std::string & dir, Version & base){
		//create dir;  
		//empty manifest file; 
		//set  CURRENT file
		//base leave emtpy
		return Result<>::OK();
	}
private:
	std::string _dir;
	VersionSet _vs;
	Version _current;
};

TEST(TestMeta, testMain){
	//init vs, v.base
	auto [ok, meta] = MetaDB::Open("meta");
	if(ok){

//		Table tab = meta.create("table1"); 
//																					
//		Table tab = meta.get("table1");
//
//		meta.drop("table1");
//
		meta->close();
		delete meta;
	}
}*/
